using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Windows.Forms;
namespace Lifter.Gui.Monitor.Controls
{
    public class LifterIDControl : BaseControl
    {
        private int borderWith = 0;
        private string equipMentId = "TLFT9900";
        private Color fillBrush = Color.White;
        private Brush borderBrush = Brushes.Blue;
        private Brush fontBrush = Brushes.White;
        private IContainer components = null;
        public string EquipMentId
        {
            get
            {
                return this.equipMentId;
            }
            set
            {
                this.equipMentId = value;
            }
        }
        public Color FillBrush
        {
            get
            {
                return this.fillBrush;
            }
            set
            {
                this.fillBrush = value;
                base.Invalidate();
            }
        }
        public Brush BorderBrush
        {
            get
            {
                return this.borderBrush;
            }
            set
            {
                this.borderBrush = value;
                base.Invalidate();
            }
        }
        public Brush FontBrush
        {
            get
            {
                return this.fontBrush;
            }
            set
            {
                this.fontBrush = value;
                base.Invalidate();
            }
        }
        public int BorderWith
        {
            get
            {
                return this.borderWith;
            }
            set
            {
                this.borderWith = value;
                base.Invalidate();
            }
        }
        public LifterIDControl()
        {
            this.InitializeComponent();
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            this.DrawBody(e.Graphics);
        }
        private void DrawBody(Graphics g)
        {
            if (g == null)
            {
                g = base.CreateGraphics();
            }
            g.SmoothingMode = SmoothingMode.HighQuality;
            g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            Rectangle rect = new Rectangle(this.borderWith, this.borderWith, base.Width - this.borderWith * 2, base.Height - this.borderWith * 2);
            //base.DrawRoundRect(g, rect, 2, this.FillBrush, this.BorderBrush, this.borderWith);
            g.FillRectangle(new SolidBrush(this.FillBrush), rect);
            Font font = new Font("Tahoma", 12f, FontStyle.Bold);
            StringFormat stringFormat = new StringFormat();
            stringFormat.Alignment = StringAlignment.Center;
            stringFormat.LineAlignment = StringAlignment.Center;
            g.DrawString(this.equipMentId, font, Brushes.AliceBlue, new RectangleF(this.borderWith, this.borderWith, base.Width - this.borderWith * 2, base.Height - this.borderWith * 2), stringFormat);
        }
        protected override void Dispose(bool disposing)
        {
            if (disposing && this.components != null)
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }
        private void InitializeComponent()
        {
            this.components = new Container();
        }
    }
}
